package com.neusoft.elmboot.controller;

import com.neusoft.elmboot.po.Food;
import com.neusoft.elmboot.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
//@RestController
@RequestMapping("food")
public class FoodController {
    @Autowired
    private FoodService foodService;
   //@RequestMapping("/list")
    @GetMapping("list")
    public String getFoodList(Model model){
        List<Food> foods = foodService.selectFoodList();
        model.addAttribute("foods",foods);
        System.out.println(foods);
        return "foodlist";
        //return foodService.selectFoodList();
    }
}
